// Page.java
package com.example.demo.utils;

import lombok.Data;
import org.springframework.data.domain.Sort;

import java.util.List;

@Data
public class Page<T> {
    private List<T> content;
    private int page;
    private int size;
    private long totalElements;
    private int totalPages;
    private Sort sort;

    public Page(List<T> content, org.springframework.data.domain.Pageable pageable, long total) {
        this.content = content;
        this.page = pageable.getPageNumber();
        this.size = pageable.getPageSize();
        this.totalElements = total;
        this.totalPages = (int) Math.ceil((double) total / size);
        this.sort = pageable.getSort();
    }
}